#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;


// 将字母转换为对应的数字
char convertCharToDigit(char c){
    if (c >= 'a' && c <= 'z') {
        c = toupper(c);
    }
    
    if (c == 'A' || c == 'B' || c == 'C') return '2';
    if (c == 'D' || c == 'E' || c == 'F') return '3';
    if (c == 'G' || c == 'H' || c == 'I') return '4';
    if (c == 'J' || c == 'K' || c == 'L') return '5';
    if (c == 'M' || c == 'N' || c == 'O') return '6';
    if (c == 'P' || c == 'R' || c == 'S') return '7';
    if (c == 'T' || c == 'U' || c == 'V') return '8';
    if (c == 'W' || c == 'X' || c == 'Y') return '9';
    
    // 如果是数字本身或无效字符直接返回
    return c;
}

// 将电话号码转换为标准格式
string standardizePhoneNumber(string& phoneNumber) {
    string result;
    int digitCount = 0;
    
    for (char c : phoneNumber) {
        char digit = convertCharToDigit(c);
        
        // 如果是有效数字且未满7位
        if (isdigit(digit) && digitCount < 7) {
            result += digit;
            digitCount++;
        }
    }
    
    // 插入连字符
    if (digitCount >= 7) {
        result.insert(3, "-");
    }
    
    return result;
}

int main() {
    int n;
    cin >> n;
    
    map<string, int> phoneCount;
    
    // 读取并处理每个电话号码
    for (int i = 0; i < n; ++i) {
        string phoneNumber;
        cin >> phoneNumber;
        
        string standard = standardizePhoneNumber(phoneNumber);
        
        if (!standard.empty()) {
            phoneCount[standard]++;
        }
    }
    
    // 收集出现次数大于1的号码
    vector<pair<string, int>> duplicates;
    for (auto& entry : phoneCount) {
        if (entry.second > 1) {
            duplicates.push_back(entry);
        }
    }
    
    // 输出结果
    for (auto& entry : duplicates) {
        cout << entry.first << " " << entry.second << endl;
    }
    
    return 0;
}